package com.mflex.mwms.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.mflex.mwms.R;
import com.mflex.mwms.adapter.CommonDecoration;
import com.mflex.mwms.adapter.RecyclerViewAdapter;
import com.mflex.mwms.listener.OnRecyclerItemClickListener;
import com.mflex.mwms.model.MenuBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TransferOffMenuActivity extends BaseActivity {
    @BindView(R.id.transfer_recycleview)
    RecyclerView recyclerView;

    private RecyclerViewAdapter adapter;
    private List<MenuBean> listDatas = new ArrayList<MenuBean>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transfer_off_menu);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        loadMenuData();

        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
        recyclerView.addItemDecoration(new CommonDecoration(this));

        adapter = new RecyclerViewAdapter(this, listDatas);
        recyclerView.setAdapter(adapter);

        adapter.setOnItemClickListener(new OnRecyclerItemClickListener() {
            @Override
            public void onRecyclerItemClick(RecyclerView parent, View view, int position) {
//                Intent intent = new Intent(TransferOffMenuActivity.this, PackWareHouseActivity.class);
////                intent.putExtra("userName", userName);
//                startActivity(intent);
                Intent intent = new Intent(TransferOffMenuActivity.this, listDatas.get(position).getTargertActivty());
//                intent.putExtra("userName", userName);
                startActivity(intent);
            }
        });
    }


    private void loadMenuData() {
//        listDatas.add(new MenuBean("任务列表", "", R.drawable.icon_more_operation_share_chat, TransferOffDetailActivity.class));
        listDatas.add(new MenuBean("调拨出库", "", R.drawable.icon_more_operation_share_chat, TransferOffActivity.class));
        listDatas.add(new MenuBean("调拨接收", "", R.drawable.icon_more_operation_share_chat, TransferOnActivity.class));
    }

    @Override
    public void onClick(View view) {

    }

    @Override
    public boolean onKey(View view, int i, KeyEvent keyEvent) {
        return false;
    }
}